<template>
    <view class="content">
        <view class="rel">
            <image class="search-bg" src="../../static/img/bg_result.png"></image>
            <view class="abs result-info" v-if="resultType !== 'empty'">
                <view class="result-tip pad-bot-s">
                    尊敬的持卡人：<br>
                      欢迎您使用单用途预付卡保险信息平台査询预付卡相关信息。您所查询
                    的预付卡对应基本信息如下，相关信息由发卡商户提供，最总结果请以发卡
                    商户与保险公司承保条款为准。如您需要进一步了解详细信息，可向发卡商 
                    家直接了解。
                </view>
                <view>
                    <view class="inb" style="letter-spacing: 17px;">企业名</view><text>称：</text>
                    <text class="inb pad-left-s">{{corpName}}</text>
                </view>
                <view>
                    <view class="inb">统一社会信用代</view><text>码：</text>
                    <text class="inb pad-left-s">{{corpCode}}</text>
                </view>
                <view>
                    <text class="inb" style="letter-spacing: 17px;">发卡余</text><text>额：</text>
                    <text class="inb pad-left-s">{{cardBalance}} 元</text>
                </view>
                <view>
                    <view class="inb" style="letter-spacing: 32px;">发卡</view><text>量：</text>
                    <text class="inb pad-left-s">{{cardAmount}} 张</text>
                </view>
                <view @click="showDetail" class="mar-ver-ss" style="color: rgb(102, 102, 102);">>>查看详情</view>
            </view>
            <view v-else class="abs-center result-info-empty">
                <!-- <view>
                    <view class="inb" style="letter-spacing: 2px;">预付卡卡</view><text>号：</text>
                    <text class="inb pad-left-s" style="color: #F23030;">6201200251117288</text>
                </view> -->
                <view>
                    <view class="inb" style="letter-spacing: 7px;">查询结</view><text>果：<text class="pad-left-s">该预付卡尚未投保《单用途商业预付卡履约保证保险》，存在预付卡资金安全隐患。预警！</text></text>
                </view>
                <view class="result-tip pad-top-s">
                    温馨提醒：<br>
                      欢迎您使用单用途预付卡保险信息平台査询预付卡相关信息。您所查询
                    的预付卡对应基本信息如下，相关信息由发卡商户提供，最总结果请以发卡
                    商户与保险公司承保条款为准。如您需要进一步了解详细信息，可向发卡商
                    家直接了解。
                </view>
            </view>
        </view>
        <news-tab></news-tab>
    </view>
</template>

<script>
    import newsTab from '../../components/newsTab.vue';
    export default {
        components: {
            newsTab
        },
        onLoad(o) {
			uni.request({
				url: 'https://unibay.cn/Api/Prepaidcard/queryInfo', //仅为示例，并非真实接口地址。
				method:"POST",
				data: {
				    cardname: o.cardName,
					cardnum: o.cardId,
					companyname: o.businessName
				},
				header: {
				    'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
				},
				success: (res) => {
					var res = res.data;
					if(res['msg'] == 'true'){
						this.resultType = 'success';
						this.corpName = res['data']['corpName'];
						this.corpCode = res['data']['corpCode'];
						this.cardBalance = res['data']['cardBalance'];
						this.cardAmount = res['data']['cardAmount'];
						// this.cardAmount = res['data']['cardAmount']; //工商注册号
						this.businessAddr = res['data']['businessAddr']; //工商注册地
						this.corpAddr = res['data']['corpAddr']; //所属地区
						this.industry = res['data']['industry']; //所属行业
						this.beian = res['data']['beian']; //备案方式
						this.recordNum = res['data']['recordNum']; //备案号
						this.phone = res['data']['phone']; //联系方式
						this.percent = res['data']['percent']; //投保比例
						this.bankCode = res['data']['bankCode']; //银行名称
						this.branchCode = res['data']['branchCode']; //支行名称
						this.depositoryMoney = res['data']['depositoryMoney']; //专用存管金额
						this.startDate = res['data']['startDate']; //存管有效期
						this.endDate = res['data']['endDate']; //存管有效期
// 						new Vue({
// 						  el: '#aaa',
// 						  data: {
// 							message: res['data']['corpName']
// 						  }
// 						});
						// console.log(res['data']['corpName']);
						// this.resultType = 'success';
					}else{
						// this.resultType = 'empty';
					}
				},
				fail: (err) => {

				},
				complete: (res) => {

				}
			})

//         	if (o && o.type) {
//                 this.resultType = o.type;
//             }
        },
        data() {
            return {
                resultType: "empty",
				corpName:'', //企业名称
				corpCode:'', //统一信用代码
				cardBalance:'', //发卡余额
				cardAmount:'', //发卡量
				// cardAmount:'-', //工商注册号
				businessAddr:'', //工商注册地
				corpAddr:'', //所属地区
				industry:'', //所属行业
				beian:'', //备案方式
				recordNum:'', //备案号
				phone:'', //联系方式
				percent:'', //投保比例
				bankCode:'', //银行名称
				branchCode:'', //支行名称
				depositoryMoney:'', //专用存管金额
				startDate:'', //存管有效期
				endDate:'', //存管有效期
            };
        },
        methods:{
            showDetail() {
				let url = "../../pages/searchResultDetail/searchResultDetail?corpName=" + this.corpName + "&corpCode=" + this.corpCode + "&cardBalance=" + this.cardBalance + "&cardAmount=" + this.cardAmount + "&businessAddr=" + this.businessAddr+ "&corpAddr=" + this.corpAddr+ "&industry=" + this.industry+ "&beian=" + this.beian+ "&recordNum=" + this.recordNum+ "&phone=" + this.phone+ "&percent=" + this.percent+ "&bankCode=" + this.bankCode + "&branchCode=" + this.branchCode + "&depositoryMoney=" + this.depositoryMoney + "&startDate=" + this.startDate + "&endDate=" + this.endDate;
                uni.navigateTo({
                	url: url
                });
            }
        }
    }
</script>

<style>
    .content {
        background-color: #f3f4f5;
    }

    .search-bg {
        width: 100%;
        height: 64vw;
        /* height: 80vw; */
    }

    .result-info {
        width: auto;
        top: 3%;
        font-size: 13px;
        padding: 0 30upx;
        color: #000000;
    }

    .result-info-empty {
        width: calc(100% - 30upx);
        font-size: 13px;
        padding: 0 30upx;
        color: #000000;
    }
    
    .result-tip {
        font-size: 12px;
        color: rgb(102, 102, 102);
        line-height: 1.5;
    }
</style>
